<template>
  <div>
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        {{ item }} <button @click="delFn(index)">删除</button>
      </li>
    </ul>
    <button @click="addFn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 1],
    };
  },
  methods: {
    addFn() {
      this.arr.push(Math.floor(Math.random() * 10));
    },
    delFn(ind) {
      return (this.arr = this.arr.filter((item, index) => index !== ind));
    },
  },
};
</script>

<style>
</style>